#coding:utf-8

#from MRockTMPLCompiler import TPLCompiler

#tc = TPLCompiler(open('FetchFavoritesInfo_Response.txt').readlines())
#tc.doCompile()

import sys,os
import shutil,re

def cur_file_dir():
	#获取脚本路径
	path = sys.path[0]
	if os.path.isdir(path):
		return path

fdict = open('__dict_MsgType.txt','r')
Dict_MsgID={}
for l in fdict.readlines():
	k = l.split('\t')
	if(len(k) == 3):	
		Dict_MsgID[int(k[0])] = k[2].strip()

a = 'qwe'
b = 'st_ssqwe'
print b[-len(a):]

for root, dirs, files in os.walk( cur_file_dir() ):
	for fn in files:
		if(fn[fn.rfind('.'):] == '.txt'):	
			funcname = fn[:fn.rfind('.')]
			for key,dictstr in Dict_MsgID.items():
				if(dictstr[-len(funcname):] == funcname):
					print funcname, '->', dictstr
					os.rename(fn, dictstr+'.txt')
				
				
				
				
		